import list from "./page.json"
import type {MockMethod} from "vite-plugin-mock";
import success from "../success.json"
import rewnew from "./renew.json"
import {findItemById} from "../utils";

export default [
    {
        url: "/tenant/list",
        method: "post",
        response: () => {
            return list;
        }
    },
    {
        url: "/tenant/detail",
        method: "get",
        response: ({query}: any) => {
            //console.log(query);
            let info = findItemById(list.data.list, query.id, "tenantId");
            let infoResult = null;
            if (info) {
                infoResult = JSON.parse(JSON.stringify(info));
            }
            if (info && info.children) {
                infoResult.children = null;
            }

            let result = JSON.parse(JSON.stringify(success));
            // @ts-ignore
            result.data = infoResult;
            return result;
        }
    },
    {
        url: "/tenant/save",
        method: "post",
        response: () => {
            return success;
        }
    },
    {
        url: "/tenant/renew/save",
        method: "post",
        response: () => {
            return success;
        }
    },
    {
        url: "/tenant/renew/log",
        method: "get",
        response: () => {
            return rewnew;
        }
    },
] as MockMethod[];
